<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        body {
            margin: 0 auto;
            padding: 0px;
            font-size: 12px;
            background: url(image/bg.gif) repeat center 36px;
            text-align: center;
            background-color: #c30230;
        }
        #content {
            margin: 0 auto;
            width: 960px;
            background: url(image/content_bg.jpg) no-repeat left top;
            height: 627px;
            position: relative;
        }

        #content .tip1, #content .tip2, #content .tip3, #content .tip4, #content .tip5, #content .tip6, #content .tip7, #content .tip8 {
            position: absolute;
            width: 227px;
            left: 200px;
            top: 100px;
        }

        #content .tip1 .tip_h {
            background: url(image/tip1_h.gif) no-repeat left top;
        }

        #content .tip1 .tip_h, #content .tip2 .tip_h, #content .tip3 .tip_h, #content .tip4 .tip_h, #content .tip5 .tip_h, #content .tip6 .tip_h, #content .tip7 .tip_h, #content .tip8 .tip_h {
            width: 227px;
            padding-top: 45px;
            height: 23px;
            text-align: left;
            cursor: move;
        }
        #content .tip1 .tip_c {
            background: url(image/tip1_c.gif) repeat-y;
        }

        #content .tip1 .tip_c, #content .tip2 .tip_c, #content .tip3 .tip_c, #content .tip4 .tip_c, #content .tip5 .tip_c, #content .tip6 .tip_c, #content .tip7 .tip_c, #content .tip8 .tip_c {
            width: 200px;
            padding-left: 12px;
            padding-right: 15px;
            min-height: 40px;
            text-align: left;
            line-height: 20px;
            max-height: 160px;
            word-wrap: break-word;
            word-break: break-all;
            overflow: hidden;
        }

        #content .tip1 .tip_f {
            background: url(image/tip1_f.gif) no-repeat left top;
        }

        #content .tip1 .tip_f, #content .tip2 .tip_f, #content .tip3 .tip_f, #content .tip4 .tip_f, #content .tip5 .tip_f, #content .tip6 .tip_f, #content .tip7 .tip_f, #content .tip8 .tip_f {
            width: 227px;
            height: 53px;
            padding-top: 20px;
        }
        #content .close, #content .close2 {
            float: left;
            font-size: 12px;
            cursor: pointer;
            color: #000000;
        }
        .clr {
            clear: both;
            overflow: auto;
            display: block;
            height: 0px;
        }
        #content .icon {
            float: left;
            width: 35px;
            padding-left: 15px;
            height: 35px;
            text-align: center;
        }
        #content .name {
            float: right;
            padding-right: 15px;
            text-align: right;
            font-size: 14px;
            line-height: 35px;
            color: #C0F;
        }
        #content .num {
            float: left;
            padding-left: 7px;
            width: 195px;
        }
    </style>
</head>
<body>
<!--纸条墙-->
	<div id="content">
		<div class="tip1" id="tip">
			<div class="tip_h" title="双击关闭纸条">
				<div class="num">第[49568]条 2016-07-7 22:51:52</div>
				<div class="close">X</div>
				<div class="clr"></div>
			</div>
			<div class="tip_c">
				普天同庆，天下大同！
			</div>
			<div class="tip_f">
				<div class="icon">
					<img src="image/bpic_1.gif" alt="" title="">
				</div>
				<div class="name">不愿意透露姓名的吕先生</div>
				<div class="clr"></div>
			</div>
		</div>
	</div>

<script>
	//需求:克隆盒子,然后随机位置,点击纸条的时候压住其他纸条
	//思路:获取纸条,克隆,随机数值绑定到纸条上,添加到父盒子中,然后绑定事件层级最高.
	//步骤:
	//1,获取纸条,克隆
	//2,随机数值绑定到纸条上
	//3,添加到父盒子中
	//4,然后绑定事件层级最高
	
	//0.创建多张纸条
	for(var i = 1;i<=10;i++){
		//1.获取纸条,克隆
		var tip = document.getElementById("tip");
		var content = document.getElementById("content");
		var newTip = tip.cloneNode(true);
		//问题:id问题
		newTip.id = newTip.id+i;
		//2.随机数值绑定到纸条上(top不要超过400，left不要超过700)
		var topValue = parseInt(Math.random()*400);
		//取值是0-1,那么乘以400,取值就是0-400
		var leftValue = parseInt(Math.random()*700);
		newTip.style.top = topValue+"px";
		newTip.style.left = leftValue+"px";
		//3.添加到父盒子中
		content.appendChild(newTip);
		//4.绑定事件层级最高
		newTip.onclick = fn;
	}
	//tip本身有问题,没有绑定事件.(1.删除 2.再绑定一次)
	tip.onclick = fn;
	//tip.parentNode.removeChild(tip);
	//获取所有类名叫做tip1标签,然后绑定事件
	var index = 1;
	function fn(){
		//计数器
		this.style.zIndex = index;
		index++;
	}
</script>



</body>
</html>